define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		//品牌
		function get_data_brands(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"brand": ['+
				'{"id": "001","name": "世达"},'+
				'{"id": "002","name": "博士"}'+
        	']},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		
		//编辑
		function get_data_brandEdit(result) {
			if(false) {
				result = '{"success": true,"msg": "","result": {"brand_id":"001"},"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		
		//返回信息
		return {
			//一级、二级、三级分类一览
			getCatList: function(cat_id,brand_id,store_id,callback) {
				Http.post({
					method: 'brand.info.getNextCatLvl',
					cat_id:cat_id,
					brand_id:brand_id,
					store_id:store_id
				},
				function(result) {
					if(callback)
						callback(result);
				},
				function(e) {
					//请求异常
				},
				function() {
					//请求完成，一般不做什么事情
				});
			},
			//编辑
			edit: function(id,brand_id,cat,region,callback) {
				var params=new Object();
			    params.id=id;
			    params.brand_id=brand_id;
			    params.cat=cat;
			    params.region=region;
			    params=JSON.stringify(params);
				Http.post({
					method: 'member.brandapply.edit',
					updateParams:params
				}, function(result) {
					if(callback)
						callback(get_data_brandEdit(result));

				}, function(e) {

				}, function() {

				})
			},
			//品牌详情
			detail:function(brand_id,callback){
				Http.post({
					method:'member.brand.detail',
					brand_id:brand_id
				}, function(result) {
					//函数回调
					if(callback)
						callback(result);
				});
			}
			
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Productmanager_brand_agent_edit", factory);
});